﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Pcb.BLL
{
    /// <summary>
    /// 系统参数
    /// </summary>
    public partial class OptionBLL
    {
        private readonly DAL.OptionDAL dal = new DAL.OptionDAL();

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        /// <param name="pageSize">每页显示多少</param>
        /// <param name="pageIndex">显示第几页</param>
        /// <param name="strWhere">查询条件,如：name='vincent'</param>
        /// <param name="filedOrder">排序字段，多个则用“,”隔开</param>
        /// <param name="recordCount">总记录数</param>
        public DataTable GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            DataTable dt = new DataTable();
            var ds = dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
            if (ds != null && ds.Tables.Count > 0)
                dt = ds.Tables[0];

            return dt;
        }

        /// <summary>
        /// 修改一列数据
        /// </summary>
        /// <param name="id">自增ID</param>
        /// <param name="strValue">如: keyValue='0.9' </param>
        public void UpdateField(int id, string strValue)
        {
            dal.UpdateField(id, strValue);
        }

        /// <summary>
        /// 修改一列数据
        /// </summary>
        /// <param name="strWhere">如：keyType='板子厚度' </param>
        /// <param name="strValue">如: keyValue='0.9' </param>
        /// <returns></returns>
        public bool UpdateField(string strWhere, string strValue)
        {
            return dal.UpdateField(strWhere, strValue);
        }

        /// <summary>
        /// 根据类名及键值名获取值
        /// </summary>
        /// <param name="typeName">类别名称</param>
        /// <param name="keyName">键值名称</param>
        /// <returns></returns>
        public float GetValue(string typeName, string keyName)
        {
            return dal.GetValue(typeName, keyName);
        }
    }
}
